class ComentasController < ApplicationController
  # GET /comentas
  # GET /comentas.xml
  def index
    @comentas = Comenta.all
	
    respond_to do |format|
      format.html # index.html.erb
      format.xml  { render :xml => @comentas }
    end
  end

  # GET /comentas/1
  # GET /comentas/1.xml
  def show
    @comenta = Comenta.find(params[:id])

    respond_to do |format|
      format.html # show.html.erb
      format.xml  { render :xml => @comenta }
    end
  end

  # GET /comentas/new
  # GET /comentas/new.xml
  def new
    @comenta = Comenta.new
	@event = Event.find(params[:eid])
	@comenta.events_id = @event.id
    respond_to do |format|
      format.html # new.html.erb
      format.xml  { render :xml => @comenta }
    end
  end

  # GET /comentas/1/edit
  def edit
    @comenta = Comenta.find(params[:id])
  end

  # POST /comentas
  # POST /comentas.xml
  def create
    @comenta = Comenta.new(params[:comenta])
	@comenta.users_id = current_user.id
    respond_to do |format|
      if @comenta.save
        flash[:notice] = 'Comenta was successfully created.'
        format.html { redirect_to(@comenta) }
        format.xml  { render :xml => @comenta, :status => :created, :location => @comenta }
      else
        format.html { render :action => "new" }
        format.xml  { render :xml => @comenta.errors, :status => :unprocessable_entity }
      end
    end
  end

  # PUT /comentas/1
  # PUT /comentas/1.xml
  def update
    @comenta = Comenta.find(params[:id])

    respond_to do |format|
      if @comenta.update_attributes(params[:comenta])
        flash[:notice] = 'Comenta was successfully updated.'
        format.html { redirect_to(@comenta) }
        format.xml  { head :ok }
      else
        format.html { render :action => "edit" }
        format.xml  { render :xml => @comenta.errors, :status => :unprocessable_entity }
      end
    end
  end

  # DELETE /comentas/1
  # DELETE /comentas/1.xml
  def destroy
    @comenta = Comenta.find(params[:id])
    @comenta.destroy

    respond_to do |format|
      format.html { redirect_to(comentas_url) }
      format.xml  { head :ok }
    end
  end
end
